package cn.xgl6.springcloud.user.controller;

import cn.xgl6.springcloud.domain.User;
import cn.xgl6.springcloud.user.service.UserService;
import cn.xgl6.springcloud.utils.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xgl
 * @create 2020-05-14 14:58
 */
@RestController
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;

@GetMapping("/user/get/{id}")
    public CommonResult<User> getUserById(@PathVariable("id") Integer id){
    User user = userService.getUserById(id);
    log.info("查询到的用户信息为" + user);
    if (null != user){
        return new CommonResult<>(200,"success",user);
    }else {
        return new CommonResult<>(200,"查不到此用户",null);
    }
}

}
